/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.model;

import java.util.Date;

import com.google.gwt.json.client.JSONObject;

/**
 *  
 */
public class ReviewModel extends AbstractModel
{
	protected int categoryId;
	protected int productId;
	protected int id;
	protected String name;
	protected int accountId;
	protected String accountName;
	protected int rating;
	protected String text;
	protected Date dateAdded;
	
	public ReviewModel() 
	{
		categoryId = 0;
		productId = 0;
		id = -1;
		name = "";
		accountId = 0;
		accountName = "";
		rating = 5;
		text = "";
		dateAdded = null;
	}
	
	public ReviewModel(JSONObject jsonObject)
	{
		categoryId = convertToInteger(jsonObject, "categories_id");
		productId = convertToInteger(jsonObject, "id");
		id = convertToInteger(jsonObject, "reviews_id");
		name = convertToString(jsonObject, "name");
		accountId = convertToInteger(jsonObject, "account_id");
		accountName = convertToString(jsonObject, "account_name");
		rating = convertToInteger(jsonObject, "rating");
		text = convertToString(jsonObject, "review_text");
		dateAdded = convertToDate(jsonObject, "review_date_added");
	}	
	
	public ReviewModel(ReviewModel model) 
	{
		categoryId = model.getCategoryId();
		productId = model.getProductId();
		id = model.getId();
		name = model.getName();
		accountId = model.getAccountId();
		accountName = model.getAccountName();
		rating = model.getRating();
		text = model.getText();
		dateAdded = model.getDateAdded();
	}
	
	public int getId() {
		return id;
	}

	public int getCategoryId() {
		return categoryId;
	}

	public int getProductId() {
		return productId;
	}

	public String getName() {
		return name;
	}

	public int getAccountId() {
		return accountId;
	}

	public String getAccountName() {
		return accountName;
	}

	public int getRating() {
		return rating;
	}

	public String getText() {
		return text;
	}
	
	public Date getDateAdded() {
		return dateAdded;
	}
}
